<?php

namespace app\beautiful\logic;

use app\beautiful\model\mall\FreightTemplateModel;

use app\beautiful\model\mall\FreightTemplatePieceModel;
use app\beautiful\model\setting\SendCityModel;


class SendLogic{

    protected $shopId;

    public function __construct($shopId)

    {

        $this->shopId=$shopId;

    }



    public function getSendPrice($send_type,$order=0)

    {
        $price = 0;
        //同城配送
        if($send_type == 3){
            if(null === $city_setting = SendCityModel::where([['shop_id','=',$this->shopId]])->json(['send_scope','order_send_time','ladder_freight_distance','ladder_freight_price'],true)->find()){

                return $price;
            }
            $price = $city_setting->base_freight;

//            $send_scope = $city_setting->send_scope;
//            $ladder_freight_price = $city_setting->ladder_freight_price;
//            $ladder_freight_distance = $city_setting->ladder_freight_distance;
//
//            if($ladder_freight_price['is_open']){
//                //原价满减
//                if($ladder_freight_price['price_type'] == 1){
//
//                    if($order['origin_price'] >= $ladder_freight_price['full']){
//                        //减全部配送费
//                        if($ladder_freight_price['reduce'] == 1){
//                            return $price;
//                        }
//                    }
//                }
//
//
//            }
//            if($ladder_freight_distance['is_open']){
//
//                //几公里内只收取基础配送费
//                $overstep_distance=$send_scope['distance']-$ladder_freight_distance['base_price_distance'];
//
//                if($overstep_distance>0){
//
//                    if(0 !== $times=$overstep_distance % $ladder_freight_distance['add_km']){
//
//                        return  $ladder_freight_distance['base_freight'] + $times*$ladder_freight_distance['freight'];
//                    }
//                }else{
//                    return $ladder_freight_distance['base_freight'];
//                }
//
//
//            }
        }

        return $price;

    }

}

